package o;

import android.content.Context;
import com.huawei.appmarket.service.usercenter.userinfo.bean.AddressBean;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class emk {
    private static emk ˊ;
    private static final Object ˎ = new Object();

    static class e {
        private InputStream ˋ;
        private BufferedReader ॱ;

        private e() {
            this.ॱ = null;
            this.ˋ = null;
        }

        public BufferedReader ॱ() {
            return this.ॱ;
        }

        public void ˊ(BufferedReader bufferedReader) {
            this.ॱ = bufferedReader;
        }

        public InputStream ˎ() {
            return this.ˋ;
        }

        public void ˎ(InputStream inputStream) {
            this.ˋ = inputStream;
        }
    }

    public static emk ˋ() {
        emk o_emk;
        synchronized (ˎ) {
            if (ˊ == null) {
                ˊ = new emk();
            }
            o_emk = ˊ;
        }
        return o_emk;
    }

    private static String ˋ(BufferedReader bufferedReader) {
        try {
            return doa.ॱ(bufferedReader, 8192);
        } catch (IOException e) {
            return null;
        }
    }

    private static e ˊ(Context context) {
        e eVar = new e();
        try {
            InputStream openFileInput = context.openFileInput("area_info");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(openFileInput, "UTF-8"));
            eVar.ˎ(openFileInput);
            eVar.ˊ(bufferedReader);
        } catch (IOException e) {
        }
        return eVar;
    }

    public ArrayList<AddressBean> ˋ(Context context) {
        int i = 1;
        ArrayList<AddressBean> arrayList = new ArrayList();
        e ˊ = ˊ(context);
        Closeable ˎ = ˊ.ˎ();
        BufferedReader ॱ = ˊ.ॱ();
        while (true) {
            try {
                String ˋ = ˋ(ॱ);
                if (ˋ == null) {
                    break;
                }
                if (!dof.ˋ(ˋ) && ॱ(ˋ, 1)) {
                    arrayList.add(ˊ(ˋ, 1, i));
                }
                i++;
            } catch (RuntimeException e) {
                arrayList = null;
            } finally {
                dnw.ˎ(ॱ);
                dnw.ˎ(ˎ);
            }
        }
        return arrayList;
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public java.util.ArrayList<com.huawei.appmarket.service.usercenter.userinfo.bean.AddressBean> ˎ(android.content.Context r7, int r8, int r9, java.lang.String r10) {
        /*
        r6 = this;
        r0 = new java.util.ArrayList;
        r0.<init>();
        r1 = ˊ(r7);
        r2 = r1.ˎ();
        r3 = r1.ॱ();
        r1 = 1;
    L_0x0012:
        r4 = ˋ(r3);	 Catch:{ RuntimeException -> 0x0036, all -> 0x003f }
        if (r4 == 0) goto L_0x0029;
    L_0x0018:
        if (r1 > r9) goto L_0x001d;
    L_0x001a:
        r1 = r1 + 1;
        goto L_0x0012;
    L_0x001d:
        r5 = o.dof.ˋ(r4);	 Catch:{ RuntimeException -> 0x0036, all -> 0x003f }
        if (r5 != 0) goto L_0x0033;
    L_0x0023:
        r5 = r4.startsWith(r10);	 Catch:{ RuntimeException -> 0x0036, all -> 0x003f }
        if (r5 != 0) goto L_0x0030;
    L_0x0029:
        o.dnw.ˎ(r3);
        o.dnw.ˎ(r2);
    L_0x002f:
        return r0;
    L_0x0030:
        r6.ˎ(r8, r0, r4, r1);	 Catch:{ RuntimeException -> 0x0036, all -> 0x003f }
    L_0x0033:
        r1 = r1 + 1;
        goto L_0x0012;
    L_0x0036:
        r0 = move-exception;
        r0 = 0;
        o.dnw.ˎ(r3);
        o.dnw.ˎ(r2);
        goto L_0x002f;
    L_0x003f:
        r0 = move-exception;
        o.dnw.ˎ(r3);
        o.dnw.ˎ(r2);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.emk.ˎ(android.content.Context, int, int, java.lang.String):java.util.ArrayList<com.huawei.appmarket.service.usercenter.userinfo.bean.AddressBean>");
    }

    private void ˎ(int i, ArrayList<AddressBean> arrayList, String str, int i2) {
        if (ॱ(str, i)) {
            arrayList.add(ˊ(str, i, i2));
        }
    }

    private AddressBean ˊ(String str, int i, int i2) {
        int i3 = 2;
        AddressBean addressBean = new AddressBean();
        addressBean.ˋ = i2;
        addressBean.ˏ = i;
        if (1 != i) {
            i3 = 2 == i ? 4 : 6;
        }
        addressBean.ˎ = str.substring(0, i3);
        addressBean.ˊ = str.substring(6, str.length());
        return addressBean;
    }

    private boolean ॱ(String str, int i) {
        boolean z = true;
        String substring = str.substring(0, 6);
        if (substring.endsWith("0000")) {
            z = true;
        } else if (substring.endsWith("00")) {
            z = true;
        }
        if (z == i) {
            return true;
        }
        return false;
    }

    public boolean ˎ() {
        eui ॱ = ॱ();
        if (!ॱ.ˏ("file_write_completed", false)) {
            return false;
        }
        long ॱ2 = ॱ.ॱ("last_update_time", 0);
        long currentTimeMillis = System.currentTimeMillis() - ॱ2;
        if (ॱ2 <= 0 || 259200000 < currentTimeMillis) {
            return false;
        }
        return true;
    }

    public eui ॱ() {
        return new eui("area_info");
    }
}
